<template>
	<!-- 钱包 -->
    <view class="content">
        <view class="mnt">
			<image src="../../static/img/64.png"></image>
			<label>我的零钱</label>
			<label>￥{{user.wallet}}</label>
			<button type="primary">充值</button>
			<!-- <button type="default">提现</button> -->
		</view>
		<cmd-bottom-nav @click="tapNav"  border-color="#BC1BBE" background-color="#BC1BBE" font-color="#fff" active-font-color="#fff"></cmd-bottom-nav>
    </view>
</template>

<script>
	import cmdBottomNav from "@/components/cmd-bottom-nav/cmd-bottom-nav.vue"
	import mbtn from "@/components/m-btn-type/m-btn.vue"
	import mtabbar from "@/components/m-tabbar/m-tabbar.vue"
	import mBtnCs from '@/components/m-btn/m-btn-cs.vue'
	import mPay from '@/components/m-pay/m-pay.vue'
	import comm from '../../common/helpers.js'
    export default {
		components:{mbtn,mtabbar,cmdBottomNav,mBtnCs,mPay},
		data(){
			return{
				itext:'订单确定',
				user:[]
			}
		},
        onLoad() {
			let that = this
			// 获取用户存储在本地的openid
			let openid = uni.getStorageSync("openid")
			//查询用户余额信息
			uni.request({
				url: comm.websiteUrl+'?s=v1/getuserid/'+openid, 
				method: 'GET',
				data: {},
				success: res => {
					// console.log(res)
					if(res.code == 404){
						uni.showModal({
							title:'警告',
							content:'用户信息获取失败，可能授权未成功，请授权之后再进入!!!',
							showCancel:false,
							confirmText:'返回授权',
							success:function(res){
								if (res.confirm) {
									console.log('用户点击了“返回授权”')
								} 
							}
						})
					}else{
						// console.log(res.data.data)
						that.user = res.data.data
					}
				},
				fail: () => {},
				complete: () => {}
			});
        },
		methods:{
			tapNav(e){
				let that = this
				let path = e.item.pagePath
				uni.switchTab({
					url:path,
					success: (res) => {
						clearInterval(that.timer)
					},
					complete: (com) => {
					}
				})
			}
		}
		
    }
</script>

<style lang="scss">
	.content{
		padding: 0upx;
		
		.mnt{
			width: 80%;
			margin: auto;
			text-align: center;
			
			image{
				width: 100upx;
				height: 100upx;
				margin: auto;
			}
			
			label{
				width:100%;
				display:flex;
				justify-content:center;
				padding:20upx 0upx;
			}
			
			button{
				width: 80%;
				height: 80upx;
				line-height: 80upx;
				margin-top: 15upx;
			}
		}
	}
</style>
